import request from "../util/request";

/**
 * 获取角色列表
 */
export const roleList = function () {
    return request.get('/role/list')
}

/**
 * 添加角色
 */
export const roleAdd = function () {
    return request.get('/role/add')
}

/**
 * 编辑角色
 */
export const roleEdit = function () {
    return request.get('/role/edit')
}

/**
 * 保存角色信息
 * @param roleInfo
 */
export const roleSave = function (roleInfo) {
    return request.post('/role/save-update', roleInfo)
}

/**
 * 获取角色权限
 * @param roleId
 * @returns {Promise<AxiosResponse<any>>}
 */
export const getRolePerms = function (roleId) {
    return request.get(`/role-menu/list/${roleId}`)
}

/**
 * 设置角色权限
 * @param roleId
 * @param permIds
 */
export const setRolePerms = function (roleId, permIds) {
    return request.post(`/role-menu/setRoleMenus/${roleId}`, permIds)
}

/**
 * 删除角色
 * @param roleId
 * @returns {Promise<AxiosResponse<any>>}
 */
export const roleDelete = function (roleId) {
    return request.delete(`/role/delete/${roleId}`)
}